#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    this->setFixedSize(QSize(750, 770));
    this->setWindowIcon(QIcon(":/icon/windowIcon.svg"));
    this->setWindowTitle(QString("钢琴块"));

    ui->setupUi(this);
    connect(ui->widget,&GameWindow::value,this,[=](int value){
        ui->lcdNumber->display(QString::number(value));
    });
    connect(ui->widget,&GameWindow::speed,this,[=](int speed){
        ui->lab_speed->setNum(speed);
    });
    connect(ui->btn_easy,&QPushButton::pressed,[this](){
        ui->widget->setRate(0.5);
        ui->lab_speed->setNum(0.5);
    });
    connect(ui->btn_normal,&QPushButton::pressed,[this](){
        ui->widget->setRate(1);
        ui->lab_speed->setNum(1);
    });
    connect(ui->btn_hard,&QPushButton::pressed,[this](){
        ui->widget->setRate(1.5);
        ui->lab_speed->setNum(1.5);
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    ui->widget->start();
    ui->widget->setFocus();
}

void MainWindow::on_pushButton_2_clicked()
{
    ui->lab_speed->setNum(0);
    ui->widget->restart();
    ui->widget->setFocus();
}
